package com.ruoyi.content.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.content.mapper.SinglePageMapper;
import com.ruoyi.content.domain.SinglePage;
import com.ruoyi.content.service.ISinglePageService;

/**
 * 单页面Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-09-11
 */
@Service
public class SinglePageServiceImpl implements ISinglePageService 
{
    @Autowired
    private SinglePageMapper singlePageMapper;

    /**
     * 查询单页面
     * 
     * @param id 单页面主键
     * @return 单页面
     */
    @Override
    public SinglePage selectSinglePageById(Integer id)
    {
        return singlePageMapper.selectSinglePageById(id);
    }

    /**
     * 查询单页面列表
     * 
     * @param singlePage 单页面
     * @return 单页面
     */
    @Override
    public List<SinglePage> selectSinglePageList(SinglePage singlePage)
    {
        return singlePageMapper.selectSinglePageList(singlePage);
    }

    /**
     * 新增单页面
     * 
     * @param singlePage 单页面
     * @return 结果
     */
    @Override
    public int insertSinglePage(SinglePage singlePage)
    {
        singlePage.setCreateTime(DateUtils.getNowDate());
        return singlePageMapper.insertSinglePage(singlePage);
    }

    /**
     * 修改单页面
     * 
     * @param singlePage 单页面
     * @return 结果
     */
    @Override
    public int updateSinglePage(SinglePage singlePage)
    {
        singlePage.setUpdateTime(DateUtils.getNowDate());
        return singlePageMapper.updateSinglePage(singlePage);
    }

    /**
     * 批量删除单页面
     * 
     * @param ids 需要删除的单页面主键
     * @return 结果
     */
    @Override
    public int deleteSinglePageByIds(Integer[] ids)
    {
        return singlePageMapper.deleteSinglePageByIds(ids);
    }

    /**
     * 删除单页面信息
     * 
     * @param id 单页面主键
     * @return 结果
     */
    @Override
    public int deleteSinglePageById(Integer id)
    {
        return singlePageMapper.deleteSinglePageById(id);
    }

    @Override
    public AjaxResult updateStatusById(SinglePage singlePage) {
        SinglePage selected = singlePageMapper.selectSinglePageById(singlePage.getId());
        if (selected == null) {
            return AjaxResult.error("未找到该页面");
        }
        singlePageMapper.updateStatusById(singlePage);
        return AjaxResult.success("修改状态成功");
    }
}
